Socket
Socket
Sign inDemoInstall

fecha

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fecha

Date formatting and parsing


Version published
Maintainers
1
Created

What is fecha?

The 'fecha' npm package is a lightweight JavaScript library for parsing, formatting, and manipulating dates. It provides a simple and flexible API for handling date and time operations.

What are fecha's main functionalities?

Date Formatting

This feature allows you to format JavaScript Date objects into strings using various format patterns. The example formats the current date into 'YYYY-MM-DD' format.

const fecha = require('fecha');
const formattedDate = fecha.format(new Date(), 'YYYY-MM-DD');
console.log(formattedDate); // Outputs: 2023-10-05

Date Parsing

This feature allows you to parse date strings into JavaScript Date objects using specified format patterns. The example parses the string '2023-10-05' into a Date object.

const fecha = require('fecha');
const parsedDate = fecha.parse('2023-10-05', 'YYYY-MM-DD');
console.log(parsedDate); // Outputs: Thu Oct 05 2023 00:00:00 GMT+0000 (Coordinated Universal Time)

Custom Formatting Tokens

This feature allows you to define custom formatting tokens for date formatting. The example defines a custom token 'custom' for time formatting and uses it to format the current time.

const fecha = require('fecha');
fecha.masks.custom = 'HH:mm:ss';
const customFormattedDate = fecha.format(new Date(), 'custom');
console.log(customFormattedDate); // Outputs: current time in 'HH:mm:ss' format

Other packages similar to fecha

Keywords

FAQs

Package last updated on 21 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc